/*
 * @Description: 自定义字段分类
 * @Author: june
 */
import request from "@/utils/request";

// 新增
export function customFieldCategorySave(customFieldCategoryAddDTO) {
  return request({
    url: "/config/api/v1/customFieldCategories",
    method: "post",
    data: customFieldCategoryAddDTO
  });
}

// 修改
export function customFieldCategoryUpdate(customFieldCategoryUpdateDTO) {
  return request({
    url: "/config/api/v1/customFieldCategories",
    method: "put",
    data: customFieldCategoryUpdateDTO
  });
}

// 单个删除
export function customFieldCategoryDelete(customFieldCategoryId) {
  return request({
    url: `/config/api/v1/customFieldCategories/${customFieldCategoryId}`,
    method: "delete"
  });
}

// 批量删除
export function customFieldCategoryDeleteBatch(customFieldCategoryIds) {
  return request({
    url: "/config/api/v1/customFieldCategories",
    method: "delete",
    data: customFieldCategoryIds
  });
}

// 根据id查找
export function customFieldCategoryFindById(customFieldCategoryId) {
  return request({
    url: `/config/api/v1/customFieldCategories/${customFieldCategoryId}`,
    method: "get"
  });
}

// 查找所有
export function customFieldCategoryListAll(customFieldCategoryQuery) {
  return request({
    url: "/config/api/v1/customFieldCategories/listAll",
    method: "get",
    customFieldCategoryQuery
  });
}

// 分页查询
export function customFieldCategoryPage(customFieldCategoryQuery) {
  let ordersParam = "";
  if (customFieldCategoryQuery.orders) {
    customFieldCategoryQuery.orders.forEach((order, index) => {
      const op = "orders[" + index + "]";
      if (ordersParam !== "") {
        ordersParam += "&";
      }
      ordersParam += op + ".property=" + order.property + "&" + op + ".desc=" + order.desc;
    });
    customFieldCategoryQuery.orders = undefined;
  }
  return request({
    url: "/config/api/v1/customFieldCategories?" + ordersParam,
    method: "get",
    params: customFieldCategoryQuery
  });
}
